<template>
	<view class="assign ff-color-000 ff-padding-bottom-130">
		<view
			class="assignTips animate__animated animate__fadeInDown ff-margin-10 ff-font-13 ff-padding-11 ff-border-radius-10 ff-line-height-1-5">
			<view class="ff-align-items-1 ff-relative ff-flex">
				<u-icon class="info-circle" name="info-circle" color="#F97522" size="31"></u-icon>
				<view class="ff-padding-left-20">
					检测到该建筑物的【自动喷水灭火系统】- “水流指示器、末端试水装置、喷头”项未拆分，请重新维护该处的数据。
				</view>
			</view>
		</view>
		<view class="ff-margin-10 ff-padding-15 ff-bg-fff ff-border-radius-10">
			<view class="ff-font-weight-600 ff-font-15">
				自动喷水灭火系统
			</view>
			<view class="ff-bg-F3F7FF ff-padding-12 ff-margin-top-10 ff-border-radius-10">
				<view class="ff-color-blue ff-margin-bottom-8">历史数据参考:</view>
				<view class="ff-color-5C5F65">水流指示器、末端试水装置、喷头：<text
						class="ff-color-blue">{{paramsSet.oldItemNumber || '0' }}</text></view>
			</view>
			<view class="">
				<view
					class="ff-flex ff-font-weight-600 ff-padding-left-15 ff-padding-right-30 ff-padding-top-10 ff-padding-bottom-10 ff-flex-between ff-bg-f8f8f8 ff-margin-top-10">
					<view class="">设施设备</view>
					<view class="">数量</view>
				</view>
				<view
					class="ff-flex ff-flex-between ff-padding-14 ff-padding-right-10 ff-align-items-1 ff-border-bottom">
					<view class="">水流指示器</view>
					<input type="number" v-model.trim="paramsSet.newItem1Number" maxlength="9"
						class="ff-text-center inp" placeholder="请输入" />
				</view>
				<view
					class="ff-flex ff-flex-between ff-padding-14 ff-padding-right-10 ff-align-items-1 ff-border-bottom">
					<view class="">末端试水装置</view>
					<input type="number" v-model.trim="paramsSet.newItem2Number" maxlength="9"
						class="ff-text-center inp" placeholder="请输入" />
				</view>
				<view
					class="ff-flex ff-flex-between ff-padding-14 ff-padding-right-10 ff-align-items-1 ff-border-bottom">
					<view class="">喷头</view>
					<input type="number" v-model.trim="paramsSet.newItem3Number" maxlength="9"
						class="ff-text-center inp" placeholder="请输入" />
				</view>
			</view>
		</view>
		<view class="forgetPassword-butList">
			<u-button type="primary" shape="circle" @click="submitClick">确定</u-button>
		</view>
		<f-loading ref="loading" />
		<u-toast ref="uToast" />
		<u-modal v-model="corrigendumModel" @confirm="corrigendumConfirm" title="温馨提示" show-cancel-button="true"
			:content-style="{ 'line-height': '1.5' }" content="请按照建筑物实际消防设施数量准确填写基础数据，后期无法再次修改本次维保数据！" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				corrigendumModel: false, // 勘误弹窗显、隐
				type: '', // 是否直接跳转执业页面
				paramsSet: {
					projectId: '',
					maintenanceId: "",
					oldItemNumber: "", // 历史数量
					newItem1Number: "", // 水流指示器数量
					newItem2Number: "", // 末端试水装置数量
					newItem3Number: "" // 喷头数量
				}
			}
		},
		onLoad(e) {
			console.log('前页面传过来的', e)
			this.paramsSet.projectId = e.projectId
			this.paramsSet.maintenanceId = e.maintenanceId
			this.paramsSet.oldItemNumber = e.oldItemNumber
			this.type = e.type || ''
		},
		methods: {
			// 提交三合一勘误
			async submitClick() {
				let that = this
				// if (!this.paramsSet.newItem1Number) {
				// 	this.$refs.uToast.show({
				// 		title: '请输入水流指示器数量',
				// 		type: 'error'
				// 	});
				// 	return;
				// }
				// if (!this.paramsSet.newItem2Number) {
				// 	this.$refs.uToast.show({
				// 		title: '请输入末端试水装置的数量',
				// 		type: 'error'
				// 	});
				// 	return;
				// }
				// if (!this.paramsSet.newItem3Number) {
				// 	this.$refs.uToast.show({
				// 		title: '请输入喷头数量',
				// 		type: 'error'
				// 	});
				// 	return;
				// }
				uni.showModal({
					title: '请确认是否提交',
					content: '不填写的默认数量为0,请谨慎核实现场数据。从本次报告起,都按照拆分后的数据进行维保。',
					confirmColor: '#3178FF',
					showCancel: true,
					confirmText: '提交',
					success: function(res) {
						if (res.confirm) {
							that.$refs.loading.openLoading('提交中···');
							that.$http.post({
								url: '/maintenance/threeMergeIntoOneItemChange',
								data: that.paramsSet
							}).then(data => {
								// console.log('三合一勘误提交返回', data)
								that.$refs.loading.closeLoading();
								if (data.code == 200) {
									if (that.type == 1) {
										// 跳转到去维保的页面
										that.$pageJump.reLaunch(
											'/pages/maintenance/mechanism/home/components/mechanismWork/mechanismWorking?maintenanceId=' +
											that.paramsSet.maintenanceId);
									} else {
										// 打开勘误提示
										that.corrigendumModel = true;
									}
								} else {
									uni.showModal({
										title: '温馨提示',
										content: data.msg,
										confirmColor: '#3178FF',
										confirmText: '好的',
										showCancel: false,
										success: function(res) {
											if (res.confirm) {
												// console.log('用户点击确定')
											}
										},
									})
								}
							})
						}
					},
				})

			},
			// 未勘误弹窗-----确定
			corrigendumConfirm() {
				// type:1 ---未勘误 维保前   type:2，维保后
				let paramsInfo = {
					projectId: this.paramsSet.projectId,
					maintenanceId: this.paramsSet.maintenanceId,
					type: 1
				};
				this.$pageJump.reLaunch(
					'/pages/maintenance/mechanism/home/components/corrigendum/Corrigendum?paramsInfo=' +
					JSON.stringify(paramsInfo));
			},
		}
	}
</script>

<style lang="scss" scoped>
	.assign {
		.assignTips {
			color: #F97522;
			background-color: #FDEFE3;
		}

		&-img {
			width: 28rpx;
			height: 28rpx;
		}

		.ff-color-1181FE {
			color: #499fff;
		}
	}

	.inp {
		background-color: #F5F5F9;
		width: 150rpx;
		padding: 10rpx;
		border-radius: 10rpx;
	}

	.forgetPassword-butList {
		width: 90%;
		margin: 15% 5%;
	}

	.info-circle {
		position: absolute;
		left: 0;
		top: 4%;
	}
</style>